<?php
namespace App\Library\System;

class App
{
    public $config, $process;

    public function __construct()
    {
        $this->config = Config::getInstance();
        $this->process = Process::getInstance();
        $this->db = Sql::getInstance();
        session_set_cookie_params(0, '/', $this->config->server);
    }

    public static function cookie($key, $value = false)
    {
        if ($value !== false) {
            $timeout = (time() + (3600 * 24) * Config::cookie_timeout);
            if ($value === 0) {
                $timeout *= -1;
            }
            setcookie($key, $value, $timeout, '/', Config::getInstance()->server, false);

            return true;
        }

        return isset($_COOKIE[$key]) ? $_COOKIE[$key] : false;
    }

    public static function session($key, $value = false)
    {
        if ($value !== false) {
            $_SESSION[$key] = $value;

            return true;
        }

        return isset($_SESSION[$key]) ? $_SESSION[$key] : false;
    }

}